/**
 * 把后端 ISO 字符串格式化成：
 * 今天 10:51
 * 明天 15:51
 * 后天 09:30
 * 7-15 18:30
 */
export function formatTaskTime(iso) {
  if (!iso) return '';

  const date = new Date(iso.replace(' ', 'T'));      // 兼容部分后端少 T
  const now   = new Date();
  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
  const targetDay = new Date(date.getFullYear(), date.getMonth(), date.getDate());

  const diffDay = Math.round((targetDay - today) / 86400000); // 相差天数

  const hours   = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const hm = `${hours}:${minutes}`;

  if (diffDay === 0) return `今天 ${hm}`;
  if (diffDay === 1) return `明天 ${hm}`;
  if (diffDay === 2) return `后天 ${hm}`;

  const md = `${date.getMonth() + 1}-${date.getDate()}`;
  return `${md} ${hm}`;
}